<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<?php
function get_drupal_text_regex($html)
{
    $body_html = "Drupal conversion failed";

   // strip the chrome
   $match = array();
   preg_match('/<div id="main".*(<div class="content".*)<div class="links"/sm', $html, $match);
   if ($match) {
       $body_html = $match[1];
   }
}

function get_drupal_text_strpos($html)
{
    $body_html = "Drupal conversion failed";
   $main_pos = strpos( $html, '<div id="main"' );
   if ($main_pos != FALSE) {
      $content_pos = strpos( $html, '<div class="content"', $main_pos );
      if ($content_pos != FALSE) {
        $links_pos = strpos( $html, '<div class="links"', $content_pos );
        if ($links_pos != FALSE) {
          $body_html = substr( $html, $content_pos, ($links_pos - $content_pos) );
        } 
      }
   }
}

function multi_test_get($uri, $times, $method)
{
    $duration = 0;
    for ($time = 0; $time < $times; $time++)
    {
	    $start = microtime(true);
    	$content = file_get_contents($uri);
		if ($method == "regex") get_drupal_text_regex($content);
		else get_drupal_text_strpos($content);
    	$duration += (microtime(true) - $start);
    }
    echo($duration." - (".$method." - ".$times." times) ".$uri."<br/>");
    return $duration;
}

function compare_methods($uri)
{
	$duration = multi_test_get($uri, 10, "regex");
	$duration = multi_test_get($uri, 10, "strpos");
}
compare_methods("http://mytec-t.twbtools.net/?q=node/197");
compare_methods("http://mytec-t.twbtools.net/?q=node/198");
compare_methods("http://mytec-t.twbtools.net/?q=node/199");
compare_methods("http://mytec-t.twbtools.net/?q=node/200");
compare_methods("http://mytec-t.twbtools.net/?q=node/201");
compare_methods("http://mytec-t.twbtools.net/?q=node/202");
compare_methods("http://mytec-t.twbtools.net/?q=node/203");
compare_methods("http://mytec-t.twbtools.net/?q=node/204");
compare_methods("http://mytec-t.twbtools.net/?q=node/205");
compare_methods("http://mytec-t.twbtools.net/?q=node/206");
compare_methods("http://mytec-t.twbtools.net/?q=node/207");
?>
